package com.suxin.datahub;

import com.suxin.job.TestJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Classname QuartzConfig
 * @Description [ TODO ]
 * @Author Tang
 * @Date 2020/11/9 14:01
 * @Created by ASUS
 */
//@Configuration
public class QuartzConfig {

    /**
     * JobDetail
     * @return
     */
    @Bean
    public JobDetail testJob() {
        return JobBuilder
                .newJob(TestJob.class)
                .withIdentity("TestJob")
                // 持久化任务
                .storeDurably()
                .build();
    }

    /**
     * testTrigger
     * @return
     */
    @Bean
    public Trigger testTrigger() {
        return TriggerBuilder.newTrigger()
                .forJob("TestJob")
                .withSchedule(
                        CronScheduleBuilder.cronSchedule("0/5 * * ? * * *")
                )
                .build();
    }


}